<!--报单详情页-->
<template>
  <div class="infinite-list-wrapper" style="overflow:auto">
    <ul v-infinite-scroll="load" class="list" infinite-scroll-disabled="disabled">
      <li v-for="(items, indexs) in list" :key="indexs" :value="items" class="list-item">
        <el-row :gutter="20">
          <el-col v-for="(item, index) in items" :key="index" :value="item" :span="6">
            <el-card class="box-card" :body-style="{ padding: '0px' }">
              <img :src="item.activityImgUrl" class="image">
              <div slot="header" class="clearfix">
                <span>{{ item.projectName }}</span>
                <span><i style="float: right; padding: 3px 0" class="el-icon-info" /></span>
              </div>
              <div style="padding: 14px;">
                <div class="bottom clearfix">
                  <time class="time">日期: {{ item.startDate }} - {{ item.endDate }}</time>
                  <el-divider direction="vertical" />
                  <el-link type="primary" class="time">总数：{{ item.total }}</el-link>
                  <el-divider direction="vertical" />
                  <el-button type="text" class="button" @click="handleInfo(item.activityId)">详情</el-button>
                </div>
              </div>
            </el-card>
          </el-col>
        </el-row>
      </li>
    </ul>
    <p v-if="loading" style="margin-top:10px;text-align:center;font-size:13px;color:#ccc">加载中...</p>
    <p v-if="noMore" style="margin-top:10px;text-align:center;font-size:13px;color:#ccc">没有更多了</p>
  </div>
</template>

<script>
import { listDetial } from '@/api/purch/purchActivity'

export default {
  data() {
    return {
      count: 10,
      loading: false,
      queryParams: {
        page: 1,
        limit: 20
      },
      list: null
    }
  },
  computed: {
    noMore() {
      return this.count >= 20
    },
    disabled() {
      return this.loading || this.noMore
    }
  },
  created() {
    this.listLoading = true
    listDetial(this.queryParams).then(response => {
      this.list = response
      setTimeout(() => { this.listLoading = false }, 1.5 * 1000)
    })
  },
  methods: {
    load() {
      this.loading = true
      setTimeout(() => {
        this.count += 2
        this.loading = false
      }, 2000)
    },
    // 详情页面
    handleInfo(id) {
      var that = this
      this.$router.push({ name: 'RebateActivityDetailInfo', query: { activityId: id }})
    }
  }
}
</script>

<style scoped>

.list {
  padding: 0;
  font-size: 14px;
}
.list-item {
  width: 100%;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  list-style: none;
  padding: 3 3rem;
  box-sizing: border-box;
  /* height: 70px; */
  /* line-height: 70px; */
  border-bottom: 1px solid #e7e7e7;
}
 .time {
    font-size: 13px;
    color: #999;
  }

  .bottom {
    margin-top: 13px;
    line-height: 12px;
  }

  .button {
    padding: 0;
    float: right;
  }

  .image {
    width: 100%;
    height: 150px;
    display: block;
  }

  .clearfix:before,
  .clearfix:after {
      display: table;
      content: "";
  }

  .clearfix:after {
      clear: both
  }
</style>

